package operation;

import book.Book;
import booklist.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-10
 * Time: 16:53
 */
public class ReturnBook implements Operation {
    @Override
    public void work(BookList booklist) {
        System.out.println("归还书籍");
        System.out.println("请输入归还的图书名称：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int cursize = booklist.getBooksize();
        int i=0;
        for( ; i<cursize; i++) {
            Book book = booklist.getpos(i);
            if( book.getName().equals(name) ) {
                book.setIsborrow(false);
                System.out.println("归还成功！");
                return ;
            }
        }
        System.out.println("没有你要归还的书！");
    }
}
